<template>
  <div class="activity-check">
    <!-- 页面标题 -->
    <div class="page-header">
      <div class="header-content">
        <h2>活动审核</h2>
        <p class="header-desc">审核和管理活动申请记录</p>
      </div>
      <div class="header-stats">
        <el-tag type="warning" size="large">待审核 {{ pendingCount }} 条</el-tag>
        <el-tooltip 
          :content="isSuperAdmin ? '可以查看和操作所有审核记录' : '可以查看：1. 自己审核的所有记录（待审核、通过、不通过）2. 所有人的审核通过记录'"
          placement="bottom"
        >
          <el-tag 
            :type="isSuperAdmin ? 'success' : 'info'" 
            size="large"
            style="margin-left: 10px; cursor: help;"
          >
            {{ isSuperAdmin ? '超级管理员 - 全部权限' : '普通管理员 - 自己的记录+通过的记录' }}
          </el-tag>
        </el-tooltip>
      </div>
    </div>

    <!-- 搜索区域 -->
    <el-card class="search-card" shadow="hover">
      <el-form :model="searchForm" inline>
        <el-form-item label="活动名称">
          <el-input
            v-model="searchForm.aname"
            placeholder="请输入活动名称"
            clearable
            style="width: 200px"
            @keyup.enter="handleSearch"
          />
        </el-form-item>
        <el-form-item label="审核状态">
          <el-select v-model="searchForm.statusCode" placeholder="请选择状态" clearable style="width: 150px">
            <el-option label="待审核" :value="0" />
            <el-option label="审核通过" :value="1" />
            <el-option label="审核不通过" :value="2" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :icon="Search" @click="handleSearch" :loading="loading">搜索</el-button>
          <el-button :icon="Refresh" @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 数据表格 -->
    <el-card class="table-card" shadow="hover">
      <div class="table-wrapper">
        <el-table
          v-loading="loading"
          :data="activityCheckList"
          stripe
          border
          style="width: 100%"
          :height="tableHeight"
        >
          <el-table-column type="index" label="序号" width="60" align="center" />
          
          <el-table-column prop="aname" label="活动名称" min-width="180" show-overflow-tooltip>
            <template #default="{ row }">
              <div class="activity-name">
                <el-icon class="activity-icon"><Calendar /></el-icon>
                <el-text class="activity-text" type="primary">{{ row.aname }}</el-text>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="ename" label="审核人员" width="120" align="center">
            <template #default="{ row }">
              <div class="reviewer-info">
                <el-icon class="user-icon"><UserFilled /></el-icon>
                <span>{{ row.ename || '未指定' }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="sname" label="学生姓名" width="120" align="center">
            <template #default="{ row }">
              <div class="student-info">
                <el-icon class="student-icon"><User /></el-icon>
                <span>{{ row.sname || '未知学生' }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="status" label="审核状态" width="120" align="center">
            <template #default="{ row }">
              <el-tag :type="getStatusTag(row.status)" size="small">
                {{ getStatusText(row.status) }}
              </el-tag>
            </template>
          </el-table-column>

          <el-table-column prop="remark" label="审核意见" min-width="200" show-overflow-tooltip>
            <template #default="{ row }">
              <div class="remark-content">
                <el-text class="remark-text" truncated>{{ row.remark || '暂无意见' }}</el-text>
                <div class="remark-preview" v-if="row.remark && row.remark.length > 30">
                  <el-tooltip :content="row.remark" placement="top">
                    <el-icon class="preview-icon"><InfoFilled /></el-icon>
                  </el-tooltip>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="createTime" label="创建时间" width="180" align="center">
            <template #default="{ row }">
              <div class="time-display">
                <span class="relative-time">{{ formatRelativeTime(row.createTime) }}</span>
                <div class="exact-time">{{ formatDateTime(row.createTime) }}</div>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="updateTime" label="修改时间" width="180" align="center">
            <template #default="{ row }">
              <div class="time-display">
                <span class="relative-time">{{ formatRelativeTime(row.updateTime) }}</span>
                <div class="exact-time">{{ formatDateTime(row.updateTime) }}</div>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="操作" width="240" align="center" fixed="right">
            <template #default="{ row }">
              <div class="operation-buttons">
                <!-- 详情按钮 - 所有状态都显示 -->
                <el-button type="primary" size="small" :icon="View" @click="handleView(row)">
                  详情
                </el-button>
                
                <!-- 待审核状态：显示审核、删除 -->
                <template v-if="parseInt(row.status) === 0">
                  <!-- 只有超级管理员或者审核人员是自己的记录才能进行审核操作 -->
                  <template v-if="isSuperAdmin || row.employeeId === currentUserId">
                    <el-button type="warning" size="small" :icon="Edit" @click="handleReview(row)">
                      审核
                    </el-button>
                    <el-button type="danger" size="small" :icon="Delete" @click="handleDelete(row)">
                      删除
                    </el-button>
                  </template>
                  <!-- 普通管理员对于不是自己的待审核记录只能查看详情 -->
                  <template v-else>
                    <el-tooltip content="您只能审核分配给您的记录" placement="top">
                      <el-button type="info" size="small" :icon="View" disabled>
                        无权限
                      </el-button>
                    </el-tooltip>
                  </template>
                </template>
                
                <!-- 审核通过状态：只显示详情、删除 -->
                <template v-else-if="parseInt(row.status) === 1">
                  <!-- 只有超级管理员才能删除审核通过的记录 -->
                  <el-button 
                    v-if="isSuperAdmin" 
                    type="danger" 
                    size="small" 
                    :icon="Delete" 
                    @click="handleDelete(row)"
                  >
                    删除
                  </el-button>
                </template>
                
                <!-- 审核不通过状态：只显示详情、删除 -->
                <template v-else-if="parseInt(row.status) === 2">
                  <!-- 只有超级管理员或审核人员是自己的记录才能删除 -->
                  <el-button 
                    v-if="isSuperAdmin || row.employeeId === currentUserId"
                    type="danger" 
                    size="small" 
                    :icon="Delete" 
                    @click="handleDelete(row)"
                  >
                    删除
                  </el-button>
                </template>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <!-- 分页 -->
      <div class="pagination-container">
        <el-pagination
          v-model:current-page="pagination.page"
          v-model:page-size="pagination.limit"
          :page-sizes="[5, 10, 20, 50, 100]"
          :total="pagination.total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-card>

    <!-- 审核详情对话框 -->
    <el-dialog
      v-model="viewDialogVisible"
      title="审核详情"
      width="700px"
      :close-on-click-modal="false"
    >
      <div v-if="currentActivityCheck" class="check-detail">
        <div class="detail-header">
          <div class="header-info">
            <h3>{{ currentActivityCheck.aname }} 的审核记录</h3>
            <p class="check-meta">
              审核人：{{ currentActivityCheck.ename || '未指定' }} | 
              学生：{{ currentActivityCheck.sname || '未知学生' }} |
              状态：<el-tag :type="getStatusTag(currentActivityCheck.status)" size="small">
                {{ getStatusText(currentActivityCheck.status) }}
              </el-tag>
            </p>
          </div>
        </div>
        
        <div class="detail-grid">
          <div class="detail-item">
            <label>活动名称：</label>
            <span>{{ currentActivityCheck.aname }}</span>
          </div>
          <div class="detail-item">
            <label>审核人员：</label>
            <span>{{ currentActivityCheck.ename || '未指定' }}</span>
          </div>
          <div class="detail-item">
            <label>学生姓名：</label>
            <span>{{ currentActivityCheck.sname || '未知学生' }}</span>
          </div>
          <div class="detail-item">
            <label>审核状态：</label>
            <el-tag :type="getStatusTag(currentActivityCheck.status)" size="small">
              {{ getStatusText(currentActivityCheck.status) }}
            </el-tag>
          </div>
          <div class="detail-item">
            <label>创建时间：</label>
            <span>{{ formatDateTime(currentActivityCheck.createTime) }}</span>
          </div>
          <div class="detail-item">
            <label>修改时间：</label>
            <span>{{ formatDateTime(currentActivityCheck.updateTime) }}</span>
          </div>
        </div>
        
        <div class="detail-item full-width">
          <label>审核意见：</label>
          <div class="remark-content-detail">
            {{ currentActivityCheck.remark || '暂无审核意见' }}
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 审核对话框 -->
    <el-dialog
      v-model="reviewDialogVisible"
      title="活动审核"
      width="600px"
      :close-on-click-modal="false"
    >
      <div class="review-content">
        <div class="activity-info">
          <h4>审核信息</h4>
          <p><strong>活动名称：</strong>{{ currentReviewData.aname }}</p>
          <p><strong>学生姓名：</strong>{{ currentReviewData.sname }}</p>
          <p><strong>审核人员：</strong>{{ currentReviewData.ename }}</p>
        </div>
        
        <el-divider />
        
        <div class="review-form">
          <el-form label-width="100px">
            <el-form-item label="审核意见">
              <el-input
                v-model="reviewForm.remark"
                type="textarea"
                :rows="4"
                placeholder="请输入审核意见"
                maxlength="500"
                show-word-limit
              />
            </el-form-item>
            
            <el-form-item label="审核结果">
              <div class="review-buttons">
                <el-button 
                  type="success" 
                  :class="{ 'active': reviewForm.status === 1 }"
                  @click="setReviewStatus(1)"
                >
                  <el-icon><Check /></el-icon>
                  审核通过
                </el-button>
                <el-button 
                  type="danger" 
                  :class="{ 'active': reviewForm.status === 2 }"
                  @click="setReviewStatus(2)"
                >
                  <el-icon><Close /></el-icon>
                  审核不通过
                </el-button>
              </div>
            </el-form-item>
          </el-form>
        </div>
      </div>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="reviewDialogVisible = false">取消</el-button>
          <el-button 
            type="primary" 
            @click="handleSubmitReview" 
            :loading="reviewLoading"
            :disabled="!reviewForm.status"
          >
            提交审核
          </el-button>
        </span>
      </template>
    </el-dialog>

  </div>
</template>

<script setup>
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
  Search,
  Refresh,
  View,
  Edit,
  Delete,
  Calendar,
  User,
  UserFilled,
  InfoFilled,
  Check,
  Close
} from '@element-plus/icons-vue'
import { queryActivityCheckList, findActivityCheck, updateActivityCheck, deleteActivityCheck } from '@/api/school'
import { useUserInfoStore } from '@/stores/userInfo'

// 用户信息store
const userInfoStore = useUserInfoStore()

// 响应式数据
const loading = ref(false)
const activityCheckList = ref([])
const viewDialogVisible = ref(false)
const currentActivityCheck = ref(null)
const reviewDialogVisible = ref(false)
const reviewLoading = ref(false)
const currentReviewData = ref({})
const pendingCount = ref(0)

// 表格高度计算
const tableHeight = computed(() => {
  return 'calc(100vh - 450px)'
})

// 判断是否为超级管理员（id为1）
const isSuperAdmin = computed(() => {
  return userInfoStore.userInfo?.id === 1
})

// 当前用户ID
const currentUserId = computed(() => {
  return userInfoStore.userInfo?.id
})

// 搜索表单
const searchForm = reactive({
  aname: '',
  statusCode: null
})

// 分页信息
const pagination = reactive({
  page: 1,
  limit: 5,
  total: 0
})

// 审核表单
const reviewForm = reactive({
  status: null,
  remark: ''
})



// 根据用户权限过滤审核记录
const filterRecordsByPermission = (records) => {
  if (!records || records.length === 0) return []
  
  // 超级管理员可以查看所有记录
  if (isSuperAdmin.value) {
    console.log('超级管理员，显示所有记录')
    return records
  }
  
  // 普通管理员只能查看：
  // 1. 自己审核的记录（所有状态：待审核、审核通过、审核不通过）
  // 2. 审核通过的记录（所有审核人员的）
  
  console.log('当前用户ID:', currentUserId.value)
  console.log('开始过滤记录，总数:', records.length)
  
  return records.filter(record => {
    console.log('正在过滤记录:', {
      id: record.id,
      employeeId: record.employeeId,
      status: record.status,
      ename: record.ename
    })
    
    // 通过审核人员ID匹配自己的记录
    const isOwnRecord = record.employeeId === currentUserId.value
    
    console.log('权限判断:', {
      recordEmployeeId: record.employeeId,
      currentUserId: currentUserId.value,
      isOwnRecord: isOwnRecord,
      recordStatus: parseInt(record.status)
    })
    
    // 自己审核的记录（所有状态：待审核、审核通过、审核不通过）
    if (isOwnRecord) {
      const statusText = parseInt(record.status) === 0 ? '待审核' : 
                        parseInt(record.status) === 1 ? '审核通过' : '审核不通过'
      console.log(`✅ 通过：自己的审核记录 (${statusText})`)
      return true
    }
    
    // 审核通过的记录（所有审核人员的）
    if (parseInt(record.status) === 1) {
      console.log('✅ 通过：他人的审核通过记录')
      return true
    }
    
    console.log('❌ 不通过：不符合查看条件')
    return false
  })
}

// 获取待审核条数
const getPendingCount = async () => {
  try {
    const params = {
      page: 1,
      limit: 1000, // 设置一个较大的数值来获取所有记录
      statusCode: 0 // 只查询待审核状态
    }
    
    const response = await queryActivityCheckList(params)
    if (response && response.code === 0) {
      // 根据权限过滤待审核记录
      const filteredRecords = filterRecordsByPermission(response.data || [])
      pendingCount.value = filteredRecords.length
      console.log('待审核条数计算:', {
        原始记录数: response.data?.length || 0,
        过滤后记录数: filteredRecords.length,
        待审核条数: pendingCount.value
      })
    }
  } catch (error) {
    console.error('获取待审核条数失败:', error)
    // 静默处理错误，不影响主要功能
  }
}

// 获取审核列表
const getActivityCheckList = async () => {
  try {
    loading.value = true
    const params = {
      page: pagination.page,
      limit: pagination.limit,
      aname: searchForm.aname || undefined,
      statusCode: searchForm.statusCode !== null ? searchForm.statusCode : undefined
    }
    
    // 调试信息：打印请求参数
    console.log('查询参数:', params)
    
    const response = await queryActivityCheckList(params)
    if (response && response.code === 0) {
        // 根据用户权限过滤记录
      const filteredRecords = filterRecordsByPermission(response.data || [])
      console.log('权限过滤结果:', {
        原始记录数: response.data?.length || 0,
        过滤后记录数: filteredRecords.length,
        当前用户ID: currentUserId.value,
        是否超级管理员: isSuperAdmin.value
      })
      
      activityCheckList.value = filteredRecords
      pagination.total = filteredRecords.length
    }
  } catch (error) {
    console.error('获取审核列表失败:', error)
    ElMessage.error('获取审核列表失败')
  } finally {
    loading.value = false
  }
}

// 搜索
const handleSearch = () => {
  pagination.page = 1
  getActivityCheckList()
}

// 重置搜索
const handleReset = () => {
  searchForm.aname = ''
  searchForm.statusCode = null
  pagination.page = 1
  getActivityCheckList()
}

// 分页大小改变
const handleSizeChange = (size) => {
  pagination.limit = size
  pagination.page = 1
  getActivityCheckList()
}

// 当前页改变
const handleCurrentChange = (page) => {
  pagination.page = page
  getActivityCheckList()
}

// 查看审核详情
const handleView = async (row) => {
  try {
    const response = await findActivityCheck(row.id)
    if (response && response.code === 0) {
      currentActivityCheck.value = response.data
      viewDialogVisible.value = true
    }
  } catch (error) {
    console.error('获取审核详情失败:', error)
    ElMessage.error('获取审核详情失败')
  }
}

// 打开审核对话框
const handleReview = (row) => {
  // 保存当前审核数据
  currentReviewData.value = { ...row }
  
  // 重置审核表单
  reviewForm.status = null
  reviewForm.remark = row.remark || ''
  
  // 显示审核对话框
  reviewDialogVisible.value = true
}

// 设置审核状态
const setReviewStatus = (status) => {
  reviewForm.status = status
  
  // 根据状态设置默认审核意见
  if (status === 1 && !reviewForm.remark.trim()) {
    reviewForm.remark = '审核通过'
  } else if (status === 2 && !reviewForm.remark.trim()) {
    reviewForm.remark = '审核不通过，请完善相关信息'
  }
}

// 提交审核
const handleSubmitReview = async () => {
  if (!reviewForm.status) {
    ElMessage.warning('请选择审核结果')
    return
  }
  
  if (!reviewForm.remark.trim()) {
    ElMessage.warning('请输入审核意见')
    return
  }
  
  if (reviewForm.remark.trim().length < 5) {
    ElMessage.warning('审核意见不能少于5个字符')
    return
  }
  
  try {
    reviewLoading.value = true
    
    const updateData = {
      id: currentReviewData.value.id,
      activityId: currentReviewData.value.activityId,
      aname: currentReviewData.value.aname,
      ename: currentReviewData.value.ename,
      sname: currentReviewData.value.sname,
      status: reviewForm.status,
      remark: reviewForm.remark.trim()
    }
    
    console.log('提交审核数据:', updateData)
    
    const response = await updateActivityCheck(updateData)
    if (response && response.code === 0) {
      ElMessage.success('审核提交成功')
      reviewDialogVisible.value = false
      getActivityCheckList()
      getPendingCount() // 更新待审核条数
    } else if (response && response.code === 4003) {
      // 活动人数已满的特殊处理
      ElMessage.warning('活动人数已满，已自动设置为审核不通过')
      reviewDialogVisible.value = false
      getActivityCheckList()
      getPendingCount()
    } else {
      // 其他错误
      ElMessage.error(response?.message || '审核提交失败')
    }
  } catch (error) {
    console.error('审核提交失败:', error)
    ElMessage.error('审核提交失败')
  } finally {
    reviewLoading.value = false
  }
}

// 删除审核
const handleDelete = (row) => {
  ElMessageBox.confirm(
    `确定要删除活动"${row.aname}"的审核记录吗？此操作不可恢复！`,
    '确认删除',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  ).then(async () => {
    try {
      const response = await deleteActivityCheck(row.id)
      if (response && response.code === 0) {
        ElMessage.success('删除成功')
        getActivityCheckList()
        getPendingCount() // 更新待审核条数
      }
    } catch (error) {
      console.error('删除审核失败:', error)
      ElMessage.error('删除审核失败')
    }
  }).catch(() => {
    ElMessage.info('已取消删除')
  })
}


// 获取状态标签
const getStatusTag = (status) => {
  // 处理字符串和数字类型的status
  const statusCode = parseInt(status)
  const tags = {
    0: 'warning',   // 待审核
    1: 'success',   // 审核通过
    2: 'danger'     // 审核不通过
  }
  return tags[statusCode] || 'info'
}

// 获取状态文本
const getStatusText = (status) => {
  // 处理字符串和数字类型的status
  const statusCode = parseInt(status)
  const texts = {
    0: '待审核',
    1: '审核通过',
    2: '审核不通过'
  }
  return texts[statusCode] || '未知状态'
}

// 格式化日期时间显示
const formatDateTime = (dateTimeStr) => {
  if (!dateTimeStr) return ''
  
  try {
    const date = new Date(dateTimeStr)
    if (isNaN(date.getTime())) return dateTimeStr
    
    const now = new Date()
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    const hours = String(date.getHours()).padStart(2, '0')
    const minutes = String(date.getMinutes()).padStart(2, '0')
    
    // 如果是今年，不显示年份
    if (year === now.getFullYear()) {
      return `${month}-${day} ${hours}:${minutes}`
    }
    
    return `${year}-${month}-${day} ${hours}:${minutes}`
  } catch (error) {
    console.error('时间格式化错误:', error)
    return dateTimeStr
  }
}

// 格式化相对时间显示
const formatRelativeTime = (dateTimeStr) => {
  if (!dateTimeStr) return ''
  
  try {
    const date = new Date(dateTimeStr)
    if (isNaN(date.getTime())) return dateTimeStr
    
    const now = new Date()
    const diffMs = now.getTime() - date.getTime()
    const diffSeconds = Math.floor(diffMs / 1000)
    const diffMinutes = Math.floor(diffSeconds / 60)
    const diffHours = Math.floor(diffMinutes / 60)
    
    // 未来时间显示为具体时间
    if (diffMs < 0) {
      return '未来时间'
    }
    
    // 今天的时间
    const today = new Date()
    today.setHours(0, 0, 0, 0)
    const dateOnly = new Date(date)
    dateOnly.setHours(0, 0, 0, 0)
    const daysDiff = Math.floor((today.getTime() - dateOnly.getTime()) / (1000 * 60 * 60 * 24))
    
    // 相对时间显示
    if (daysDiff === 0) {
      // 今天
      if (diffSeconds < 60) {
        return '刚刚'
      } else if (diffMinutes < 60) {
        return `${diffMinutes}分钟前`
      } else {
        return `${diffHours}小时前`
      }
    } else if (daysDiff === 1) {
      return '昨天'
    } else if (daysDiff === 2) {
      return '前天'
    } else if (daysDiff < 7) {
      return `${daysDiff}天前`
    } else if (daysDiff < 30) {
      const weeks = Math.floor(daysDiff / 7)
      return `${weeks}周前`
    } else if (daysDiff < 365) {
      const months = Math.floor(daysDiff / 30)
      return `${months}个月前`
    } else {
      const years = Math.floor(daysDiff / 365)
      return `${years}年前`
    }
  } catch (error) {
    console.error('相对时间格式化错误:', error)
    return formatDateTime(dateTimeStr)
  }
}

// 页面加载时获取数据
onMounted(() => {
  // 调试信息：打印用户信息
  console.log('当前用户信息:', userInfoStore.userInfo)
  console.log('是否为超级管理员:', isSuperAdmin.value)
  console.log('当前用户ID:', currentUserId.value)
  
  getActivityCheckList()
  getPendingCount()
})
</script>

<style scoped>
.activity-check {
  padding: 5px 20px 20px 20px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  
  /* 自定义滚动条样式 */
  scrollbar-width: thin;
  scrollbar-color: #c1c1c1 #f1f1f1;
}

/* Webkit浏览器滚动条样式 */
.activity-check::-webkit-scrollbar {
  width: 8px;
}

.activity-check::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.activity-check::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.activity-check::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

.page-header {
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px 0;
  border-bottom: 2px solid #e4e7ed;
}

.header-content h2 {
  margin: 0 0 4px 0;
  font-size: 28px;
  font-weight: 700;
  color: #303133;
  background: linear-gradient(135deg, #409eff, #67c23a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-desc {
  margin: 0;
  font-size: 14px;
  color: #909399;
  font-weight: 400;
}

.header-stats {
  display: flex;
  align-items: center;
}

.search-card {
  margin-bottom: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.search-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.table-card {
  background-color: #fff;
  margin-bottom: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.table-wrapper {
  flex: 1;
  overflow: hidden;
}

/* 表格内容样式 */
.activity-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.activity-icon {
  color: #409eff;
  font-size: 16px;
}

.activity-text {
  font-weight: 600;
}

.reviewer-info, .student-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-icon {
  color: #67c23a;
  font-size: 14px;
}

.student-icon {
  color: #e6a23c;
  font-size: 14px;
}

.remark-content {
  max-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.remark-text {
  line-height: 1.4;
  color: #606266;
  flex: 1;
}

.remark-preview {
  flex-shrink: 0;
}

.preview-icon {
  color: #909399;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.preview-icon:hover {
  color: #409eff;
}

/* 操作按钮样式 */
.operation-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 40px;
}

:deep(.operation-buttons .el-button) {
  margin: 0 !important;
  min-width: 48px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  border-radius: 6px;
  font-weight: 500;
  font-size: 12px;
  padding: 0 8px;
}

:deep(.operation-buttons .el-button:hover) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

:deep(.operation-buttons .el-button:active) {
  transform: translateY(0);
}

/* 特定按钮样式优化 */
:deep(.operation-buttons .el-button--success) {
  background: linear-gradient(135deg, #67c23a, #85ce61);
  border: none;
}

:deep(.operation-buttons .el-button--success:hover) {
  background: linear-gradient(135deg, #5daf34, #67c23a);
}

:deep(.operation-buttons .el-button--danger) {
  background: linear-gradient(135deg, #f56c6c, #f78989);
  border: none;
}

:deep(.operation-buttons .el-button--danger:hover) {
  background: linear-gradient(135deg, #f25656, #f56c6c);
}

.pagination-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 16px;
  margin-bottom: 10px;
  padding: 16px 20px;
  flex-shrink: 0;
  background-color: #fff;
  border-top: 1px solid #ebeef5;
}

/* 审核详情样式 */
.check-detail {
  padding: 16px 0;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #ebeef5;
}

.header-info h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: #303133;
}

.check-meta {
  margin: 0;
  color: #909399;
  font-size: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-item {
  display: flex;
  align-items: flex-start;
}

.detail-item.full-width {
  grid-column: 1 / -1;
  flex-direction: column;
}

.detail-item label {
  font-weight: 600;
  color: #606266;
  min-width: 80px;
  margin-right: 12px;
}

.detail-item.full-width label {
  margin-bottom: 8px;
}

.remark-content-detail {
  background: #f5f7fa;
  padding: 16px;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #303133;
  border-left: 4px solid #409eff;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

:deep(.el-table th) {
  background: linear-gradient(135deg, #f5f7fa, #eef1f6);
  color: #303133;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 2px solid #e4e7ed;
}

:deep(.el-table td) {
  padding: 16px 0;
  border-bottom: 1px solid #f0f2f5;
}

:deep(.el-table .el-table__row:hover) {
  background-color: #f8f9fa;
}

:deep(.el-table .el-table__row) {
  transition: background-color 0.3s ease;
}

/* 时间显示样式 */
.time-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.relative-time {
  font-weight: 500;
  color: #409eff;
  font-size: 13px;
  cursor: help;
}

.exact-time {
  font-size: 11px;
  color: #909399;
  line-height: 1.2;
}

/* 响应式优化 */
@media screen and (max-width: 768px) {
  .activity-check {
    padding: 5px 15px 5px 15px;
    max-height: calc(100vh - 50px);
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 0;
  }
  
  .header-content h2 {
    font-size: 24px;
  }
  
  .pagination-container {
    justify-content: center;
    margin-bottom: 8px;
    padding: 12px 15px;
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
  
  .operation-buttons {
    gap: 6px;
  }
  
  :deep(.operation-buttons .el-button) {
    min-width: 45px !important;
    height: 28px !important;
    font-size: 12px !important;
  }
  
  .remark-content {
    max-width: 150px;
  }
}

/* 审核对话框样式 */
.review-content {
  padding: 10px 0;
}

.activity-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.activity-info h4 {
  margin: 0 0 10px 0;
  color: #303133;
  font-size: 16px;
  font-weight: 600;
}

.activity-info p {
  margin: 8px 0;
  color: #606266;
  font-size: 14px;
  line-height: 1.5;
}

.review-form {
  padding: 0 5px;
}

.review-buttons {
  display: flex;
  gap: 15px;
  align-items: center;
}

.review-buttons .el-button {
  min-width: 120px;
  height: 40px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.review-buttons .el-button.active {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.review-buttons .el-button--success.active {
  background: linear-gradient(135deg, #67c23a, #85ce61);
  border-color: #67c23a;
}

.review-buttons .el-button--danger.active {
  background: linear-gradient(135deg, #f56c6c, #f78989);
  border-color: #f56c6c;
}

.review-buttons .el-button:hover {
  transform: translateY(-2px);
}

.review-buttons .el-button.active:hover {
  transform: scale(1.05) translateY(-2px);
}

:deep(.review-content .el-form-item__label) {
  font-weight: 600;
  color: #303133;
}

:deep(.review-content .el-textarea__inner) {
  border-radius: 8px;
  border: 2px solid #e4e7ed;
  transition: border-color 0.3s ease;
}

:deep(.review-content .el-textarea__inner:focus) {
  border-color: #409eff;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.1);
}
</style>